<template>
  <div style="margin-top: 20px; padding: 20px 300px 10px 60px">
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="商品分类名称">
        <el-input v-model="params.typeName"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="edit">修改</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getType } from "@/api/type";
import { editType } from "@/api/type";

export default {
  data() {
    return {
      form: {
        typeName: "",
      },
      params: {
        typeName: "",
        typeId: this.$route.query.typeId,
      },
    };
  },
  methods: {
    edit() {
      console.log(this.params)
      editType(this.params).then((res) => {
        this.$message.success("修改成功");
        this.$router.push("/type/list");
      });
    },
    show() {
      getType(this.$route.query.typeId)
        .then((res) => {
          // console.log(res);
          this.params.typeName = res.data;
        })
        .catch((reason) => {});
    },
    onSubmit() {
      console.log("submit!");
    },
  },
  created() {
    this.show();
  },
};
</script>

<style>
</style>
